package com.leetcode.August;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 78. 子集
 * @Author: Mr.Fxy
 * @CreateTime: 2024-08-05 09:22
 */
public class LC78子集 {
    List<List<Integer>> ls = new ArrayList<>();
    public List<List<Integer>> subsets(int[] nums) {
        backtrack(new ArrayList<>(), nums, 0);//从第一个开始
        return ls;
    }

    public void backtrack(List<Integer> num, int[] nums, int start) {
        ls.add(num);
        for (int i = start; i < nums.length; i++) {
            List<Integer> temp = new ArrayList<>(num);
            temp.add(nums[i]);
            backtrack(temp, nums, i + 1);
        }
    }
}
